<?php

namespace App\Http\Requests\Logic\User;

use Illuminate\Foundation\Http\FormRequest;

class StoreResource extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

	/**
	 * 定义表单规则
	 *
	 * Date: 12/04/2018
	 * @author George
	 * @return array
	 */
    public function rules()
    {
        return [
        	'name' => 'required',
        	'mobile' => ['required', 'regex:/^(1[3|4|5|6|7|8|9])\d{9}$/', 'unique:users,mobile'],
        	'password' => 'required|confirmed|alpha_num|min:6|max:18',
        	'birthday' => 'required',
        	'gender' => 'required',
        	'identification' => 'required|unique:users',
        	'company_id' => 'required',
			'department_id' => 'required',
        	'project_id' => 'required',
        	'position_id' => 'required',
        	'certificate' => 'nullable',
        	'stature' => 'required',
        	'education' => 'required',
        	'dormitory' => 'nullable',
        	'address' => 'nullable',
        	'marital' => 'required',
        	'urgency_name' => 'required',
        	'urgency_mobile' => 'required',
        	'urgency_relation' => 'required',
        	'trade' => 'required',
        	'fingerprint' => 'required',
        	'transaction' => 'required',
        	'expiry' => 'required',
        	'skill' => 'nullable',
        	'channel' => 'nullable',
        	'debit' => 'required',
        	'issuer' => 'required',
        	'hometown' => 'required',
        	'identification_front' => 'required',
        	'identification_reverse' => 'required',
        ];
    }

	/**
	 * 定义错误响应消息
	 *
	 * Date: 12/04/2018
	 * @author George
	 * @return array
	 */
	public function messages()
	{
		return [
			'name.required' => '请输入姓名',
			'mobile.required' => '请输入手机号码',
			'mobile.regex' => '您输入的手机号码有误',
			'mobile.unique' => '您输入的手机号码已存在',
			'password.required' => '请输入密码',
			'password.password_confirmation' => '验证密码不匹配',
			'password.alpha_num' => '密码只能是英文字母或数字',
			'password.min' => '密码不得少于:min个字符',
			'password.max' => '密码不得少于:max个字符',
			'identification.required' => '请输入身份证号',
			'urgency_name.required' => '请输入紧急联系人姓名',
			'urgency_mobile.required' => '请输入紧急联系人手机',
			'urgency_relation.required' => '请输入紧急联系人关系',
			'identification.identification' => '您输入的身份证信息已存在',
			'manager.boolean' => '管理者选项的值只能为真或假'
		];
    }
}
